import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import SlideVerify from 'vue-monoplasty-slide-verify';

Vue.use(SlideVerify);

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI)

import axios from "axios"
axios.defaults.baseURL = "http://127.0.0.1:7001/"

// 导入 NProgress 包对应的JS和CSS
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 在 request 拦截器中，展示进度条 NProgress.start()
axios.interceptors.request.use(config => {
  // console.log(config)
  NProgress.start()
  config.headers.Authorization = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFhYSIsInBhc3N3b3JkIjoiYWFhIiwiaWF0IjoxNjE4MzkwMzE3fQ.XVXtfC2PxHpFvpEpwDO8YcJ6yZjcW6IM5oRPlfPzElc"
  // 在最后必须 return config
  return config
})
// 在 response 拦截器中，隐藏进度条 NProgress.done()
axios.interceptors.response.use(config => {
  NProgress.done()
  // loading.close()
  if(config.data.code == 404){
    return router.push("/404")
  }
  return config
})


Vue.prototype.$axios = axios
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
